
#include <stdio.h>

#define FILENAME "e:\\weirmega.dat"
#define CHUNK 500

int main()
{
  printf("=????\n");
    FILE *file_handle;
    char buf1[CHUNK],buf2[CHUNK];
    char pair[3];
    char *fbuf;
    char *bbuf;
    char *swap;
    int r, i;

    file_handle=fopen(FILENAME,"r");
    if (!file_handle)
        return 1;
        
        
    fseek(file_handle,0,SEEK_END);
    int size = ftell(file_handle);
    printf("%i MB",size / 1024 / 1024 );
    
    fseek(file_handle,0,SEEK_BEG);

    fbuf=buf1;
    bbuf=buf2;

    r=(int)fread( fbuf, sizeof(char), CHUNK, file_handle );
    if ( !r || r<CHUNK )
        return 1;
        
    printf("r=%i",r);

    pair[2]=0;
    while ( (r=(int)fread( bbuf, sizeof(char), CHUNK, file_handle )) ) {
        for( i=0;i<r;i++ ) {
            pair[0]=fbuf[i];
            pair[1]=bbuf[i];
            /* printf("%s\n",pair);*/
        }
        /* Move old back buffer pointer to front buffer ptr
         * And vice versa. Net effect is to slide buffer->R
         * As we will refil the back buffer with fresh data.
         * Thus we simply pour data from disk to memory with
         * no wasted copying effort.
         */
        swap=fbuf;
        fbuf=bbuf;
        bbuf=swap;
    }

    fclose(file_handle);
    return 0;
}
